package cn.xinjiu.reggie.common;

/**
 * Created by xinchen on 2022/7/4
 *
 * @Description : 基于ThreadLocal封装工具类，用于保存和获取当前登录的用户id
 *      使用线程为作用域，不会使数据混淆
 */
public class BaseContext {
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    /**
     * @param id
     * @return
     * @description 设置值
     */
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }

    /**
     * @param
     * @return 上边方法设置的值
     * @description 获取值
     */
    public static Long getCurrentId(){
        return threadLocal.get();
    }
}
